#include <iostream>
using namespace std;

class A{
    virtual void func(){
        cout<<"A's func is called"<<endl;
    }
};

class B:public A{
    virtual void func(){
        cout<<"B's func is called"<<endl;
    }
};

A globalA;

void tempFunc(){
	cout<<"globalA: "<<*(void**)&globalA<<endl;
	A tempa;
	cout<<"temp addressof A is: "<<*(void**)&tempa<<endl;
}
int main(){

	tempFunc();
    A a;
    B b;
    cout<<"Vtable address of A is"<<*(void**)&a<<endl;
    cout<<"Vtable address of B is"<<*(void**)&b<<endl;
    A tmp=b;
	
	tmp.func();
    cout<<"after upcast and copy:  "<<*(void**)&tmp<<endl;
    A* p=&b;
    cout<<"after upcast and reference:  "<<*(void**)&(*p)<<endl;
}
